package com.zyf.school.manager.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zyf.school.manager.domain.Course;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
@Component(value = "courseDao")
public interface CourseDao extends BaseMapper<Course> {
    //插入数据
    @Insert("insert into course(name,price,unit,grade,subject,type,dictid,state) values(#{name},#{price},#{unit},#{grade},#{subject},#{type},#{dictid},#{state})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public int insert(Course course);
    //查询数据
    @Select("select * from course where dictid = #{dictid}")
    public List<Course> queryByDict(int dictid);

    //更新数据
    @Update("update course set name=#{name},price=#{price},unit=#{unit},grade=#{grade},subject=#{subject},type=#{type},dictid=#{dictid},state=#{state} where id = #{id}")
    public void update(Course course);

    //删除数据
    @Delete("delete from course where id = #{id}")
    public void delete(int id);
}
